<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>$.get()加载XML文档</title>
		<style type="text/css">
			*{margin: 0;padding: 0;}
			body{font-size: 14px;}
			.divFrame{width: 260px;border: 1px solid red;}
			.divFrame .divTitle{padding: 5px;background: #eee;}
			.divFrame .divContent{padding: 8px;}
			.divFrame .divContent .clsShow{font-size: 14px;}
			.btn{border: 1px solid green;padding: 2px;width: 80px;filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr=#ffffff,EndColorStr=#ECE0D8);}
		</style>
	</head>
	<body>
		<!--$.get(url,[data],[callback],[type])-->
		<div class="divFrame">
			<div class="divTitle">
				<input type="button" id="button" class="btn" value="获取数据"/>
			</div>
			<div class="divContent">
				<div id="divTip"></div>
			</div>
		</div>
		<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
		<script type="text/javascript">
			$(function(){
				$("#button").click(function(){
					$.get("User.xml",function(data){
						$("#divTip").empty();
						var strHTML = "";
						$(data).find("User")
						.each(function(){
							var $strUser = $(this);
							strHTML += "姓名：" + $strUser.find("name").text()+"<br/>";
							strHTML += "性别：" + $strUser.find("sex").text()+"<br/>";
							strHTML += "邮箱：" + $strUser.find("email").text()+"<br/>";
						});
						$("#divTip").html(strHTML);
					});
				});
			});
		</script>
	</body>
</html>
